home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / GAS_1_38.ARJ / MESSAGES.C < prev    next >
C/C++ Source or Header  |  1991-01-04  |  5KB  |  239 lines

  1. /* messages.c - error reporter -
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>        /* define stderr */
  21. #ifdef    VMS
  22. #include <errno.h>    /* Need this to make errno declaration right */
  23. #include <perror.h>    /* Need this to make sys_errlist/sys_nerr right */
  24. #endif /* VMS */
  25.  
  26. #include "as.h"
  27.  
  28. #ifndef NO_VARARGS
  29. #include <varargs.h>
  30. #endif
  31.  
  32. /*
  33.         ERRORS
  34.  
  35.     JF: this is now bogus.  We now print more standard error messages
  36.     that try to look like everyone else's.
  37.  
  38.     We print the error message 1st, beginning in column 1.
  39.     All ancillary info starts in column 2 on lines after the
  40.     key error text.
  41.     We try to print a location in logical and physical file
  42.     just after the main error text.
  43.     Caller then prints any appendices after that, begining all
  44.     lines with at least 1 space.
  45.  
  46.     Optionally, we may die.
  47.     There is no need for a trailing '\n' in your error text format
  48.     because we supply one.
  49.  
  50. as_warn(fmt,args)  Like fprintf(stderr,fmt,args) but also call errwhere().
  51.  
  52. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  53.  
  54. */
  55.  
  56.  
  57. /* Nonzero if we've hit a 'bad error', and should not write an obj file,
  58.    and exit with a nonzero error code */
  59.  
  60. int bad_error = 0;
  61.  
  62.  
  63. /*
  64.  *            a s _ p e r r o r
  65.  *
  66.  * Like perror(3), but with more info.
  67.  */
  68. /* JF moved from input-scrub.c to here.  */
  69. void
  70. as_perror(gripe, filename)
  71.      char *    gripe;        /* Unpunctuated error theme. */
  72.      char *    filename;
  73. {
  74.   extern int errno;        /* See perror(3) for details. */
  75.   extern int sys_nerr;
  76.   extern char * sys_errlist[];
  77.  
  78.   as_where();
  79.   fprintf (stderr,gripe,filename);
  80.   if (errno > sys_nerr)
  81.     fprintf (stderr, "Unknown error #%d.\n", errno);
  82.   else
  83.     fprintf (stderr, "%s.\n", sys_errlist [errno]);
  84.   errno = 0;            /* After reporting, clear it. */
  85. }
  86.  
  87. /*
  88.  *            a s _ w a r n ( )
  89.  *
  90.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  91.  * in input file(s).
  92.  * Please only use this for when we have some recovery action.
  93.  * Please explain in string (which may have '\n's) what recovery was done.
  94.  */
  95.  
  96. #ifdef NO_VARARGS
  97. /*VARARGS1*/
  98. as_warn(Format,args)
  99. char *Format;
  100. {
  101.   if ( ! flagseen ['W'])    /* -W supresses warning messages. */
  102.     {
  103.       as_where();
  104.       _doprnt (Format, &args, stderr);
  105.       (void)putc ('\n', stderr);
  106.       /* as_where(); */
  107.     }
  108. }
  109. #else
  110. void
  111. as_warn(Format,va_alist)
  112. char *Format;
  113. va_dcl
  114. {
  115.   va_list args;
  116.  
  117.   if( ! flagseen['W'])
  118.     {
  119.       as_where();
  120.       va_start(args);
  121.       vfprintf(stderr, Format, args);
  122.       va_end(args);
  123.       (void) putc('\n', stderr);
  124.     }
  125. }
  126. #endif
  127. #ifdef DONTDEF
  128. void
  129. as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  130. char *format;
  131. {
  132.     if(!flagseen['W']) {
  133.         as_where();
  134.         fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  135.         (void)putc('\n',stderr);
  136.     }
  137. }
  138. #endif
  139. /*
  140.  *            a s _ b a d ( )
  141.  *
  142.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning,
  143.  * and locate warning in input file(s).
  144.  * Please us when there is no recovery, but we want to continue processing
  145.  * but not produce an object file.
  146.  * Please explain in string (which may have '\n's) what recovery was done.
  147.  */
  148.  
  149. #ifdef NO_VARARGS
  150. /*VARARGS1*/
  151. as_bad(Format,args)
  152. char *Format;
  153. {
  154.   bad_error=1;
  155.   as_where();
  156.   _doprnt (Format, &args, stderr);
  157.   (void)putc ('\n', stderr);
  158.   /* as_where(); */
  159. }
  160. #else
  161. void
  162. as_bad(Format,va_alist)
  163. char *Format;
  164. va_dcl
  165. {
  166.   va_list args;
  167.  
  168.   bad_error=1;
  169.   as_where();
  170.   va_start(args);
  171.   vfprintf(stderr, Format, args);
  172.   va_end(args);
  173.   (void) putc('\n', stderr);
  174. }
  175. #endif
  176. #ifdef DONTDEF
  177. void
  178. as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  179. char *format;
  180. {
  181.     as_where();
  182.     bad_error=1;
  183.     fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  184.     (void)putc('\n',stderr);
  185. }
  186. #endif
  187. /*
  188.  *            a s _ f a t a l ( )
  189.  *
  190.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  191.  * message, and locate stdsource in input file(s).
  192.  * Please only use this for when we DON'T have some recovery action.
  193.  * It exit()s with a warning status.
  194.  */
  195.  
  196. #ifdef NO_VARARGS
  197. /*VARARGS1*/
  198. as_fatal (Format, args)
  199. char *Format;
  200. {
  201.   as_where();
  202.   fprintf(stderr,"FATAL:");
  203.   _doprnt (Format, &args, stderr);
  204.   (void)putc ('\n', stderr);
  205.   /* as_where(); */
  206.   exit(42);            /* What is a good exit status? */
  207. }
  208. #else
  209. void
  210. as_fatal(Format,va_alist)
  211. char *Format;
  212. va_dcl
  213. {
  214.   va_list args;
  215.  
  216.   as_where();
  217.   va_start(args);
  218.   fprintf (stderr, "FATAL:");
  219.   vfprintf(stderr, Format, args);
  220.   (void) putc('\n', stderr);
  221.   va_end(args);
  222.   exit(42);
  223. }
  224. #endif
  225. #ifdef DONTDEF
  226. void
  227. as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  228. char *Format;
  229. {
  230.   as_where();
  231.   fprintf (stderr, "FATAL:");
  232.   fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  233.   (void) putc('\n', stderr);
  234.   exit(42);
  235. }
  236. #endif
  237.  
  238. /* end: messages.c */
  239.